package com.gyt.manager.controller.risk;

import com.gyt.manager.common.base.BaseController;
import com.gyt.manager.common.base.response.Page;
import com.gyt.manager.common.base.response.Response;
import com.gyt.manager.domain.req.TaskWhiteDaysReq;
import com.gyt.manager.domain.req.TaskWhiteReq;
import com.gyt.manager.domain.risk.TaskWhiteInfo;
import com.gyt.manager.service.TaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author gyt on 2021/4/28 12:27
 */
@RestController
@RequestMapping("resource")
@Api(tags = "resource-task", description = "资源中心-任务", value = "task")
public class TaskController extends BaseController {

    @Autowired
    private TaskService taskService;

    @PostMapping("task/batchAddTaskWhite.do")
    @ApiOperation(value = "批量新增任务白名单", notes = "任务")
    public Response<Boolean> batchAddTaskWhite(
            @ApiParam(value = "id集合", required = true)
            @RequestBody final List<Long> ids) {
        Boolean flag = taskService.batchAddTaskWhite(ids);
        return Response.ok(flag);
    }

    @PostMapping("task/batchUpdateTaskWhiteDays.do")
    @ApiOperation(value = "批量新增任务白名单", notes = "任务")
    public Response<Boolean> batchUpdateTaskWhiteDays(
            @ApiParam(value = "请求体", required = true)
            @RequestBody final TaskWhiteDaysReq taskWhiteDaysReq) {
        Boolean flag = taskService.batchUpdateTaskWhiteDays(taskWhiteDaysReq);
        return Response.ok(flag);
    }

    @PostMapping("task/findTaskInfos.do")
    @ApiOperation(value = "查询白名单任务信息列表")
    public Response<Page<TaskWhiteInfo>> findTaskInfos(
            @ApiParam(value = "请求体", required = true)
            @RequestBody final TaskWhiteReq taskWhiteReq) {
        Page<TaskWhiteInfo> result = taskService.findTaskInfos(taskWhiteReq);
        return Response.ok(result);
    }
}
